package com.cake.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cake.base.util.ReturnUtils;
import com.cake.entity.XxRefunds;
import com.cake.service.inter.IXxRefundsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 *	退款单控制层
 * @author Administrator
 *
 */
@RestController
@RequestMapping(value = "refunds")
public class RefundsController {

	@Autowired
	private IXxRefundsService xxRefundsService;
	
	/**
	 * 查询退款单列表
	 * @return
	 * @throws Exception 
	 */
	@PostMapping(value = "selectRefundses")
	public Object selectRefundses(@RequestBody XxRefunds xxRefunds) throws Exception{
		PageHelper.startPage(xxRefunds.getCurrentPage(), xxRefunds.getPageSize());
		List<XxRefunds> list = xxRefundsService.selectByAttributeAnd(xxRefunds);
		PageInfo<XxRefunds> page = new PageInfo<>(list);
		return ReturnUtils.forNoramlPage("000000", list, 
				page.getPageNum(), page.getPageSize(), page.getPages(), (int)page.getTotal());
	}
	
	/**
	 * 根据id查询一条退款单详情
	 * @return
	 * @throws Exception 
	 */
	@GetMapping(value = "selectRefundsById")
	public Object selectRefundsById(Long refundsId) throws Exception{
		return ReturnUtils.forNoramlSuccess(xxRefundsService.selectByPrimaryKey(refundsId));
	}
	
}
